package foodmaterial.entity;

import foodmaterial.action.valid.ObjectNullValid;

import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

public class PurchaseBillDetails implements Serializable,Comparable<PurchaseBillDetails> {
    private static final long serialVersionUID = 7689049856057748578L;

    private Long id;
    private Long purchaseBillId ;// '参照采购单id',
    @ObjectNullValid(message = "食材不能为空")
    private Long foodMaterialId;// '食材',
    private String foodMaterialName ;
    private String foodMaterialTypeName ;
    private String specs;// '规格',
    private String brand ; //'品牌',
    private String unitName ;
    private Integer planAmount ;//计划数量
    @ObjectNullValid(message = "进货价不能为空")
    @DecimalMin(value = "0.01",message = "进货价最低为{value}")
    @DecimalMax(value = "300",message = "进货价最高为{value}")
    private BigDecimal price ; //'价格（进货价）'
    @ObjectNullValid(message = "采购数量不能为空")
    @Min(value=1,message = "采购数量至少为{value}")
    @Max(value=100000,message = "采购数量最多为{value}")
    private Integer amount ;// '数量'
    private BigDecimal total;//总价
    private Date lastBuyDate ;//用来比较跟新食材买入价格
    private Boolean originalProcess ;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getPurchaseBillId() {
        return purchaseBillId;
    }

    public void setPurchaseBillId(Long purchaseBillId) {
        this.purchaseBillId = purchaseBillId;
    }

    public Long getFoodMaterialId() {
        return foodMaterialId;
    }

    public void setFoodMaterialId(Long foodMaterialId) {
        this.foodMaterialId = foodMaterialId;
    }

    public String getFoodMaterialName() {
        return foodMaterialName;
    }

    public void setFoodMaterialName(String foodMaterialName) {
        this.foodMaterialName = foodMaterialName;
    }

    public String getFoodMaterialTypeName() {
        return foodMaterialTypeName;
    }

    public void setFoodMaterialTypeName(String foodMaterialTypeName) {
        this.foodMaterialTypeName = foodMaterialTypeName;
    }

    public String getSpecs() {
        return specs;
    }

    public void setSpecs(String specs) {
        this.specs = specs;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getUnitName() {
        return unitName;
    }

    public void setUnitName(String unitName) {
        this.unitName = unitName;
    }

    public Integer getPlanAmount() {
        return planAmount;
    }

    public void setPlanAmount(Integer planAmount) {
        this.planAmount = planAmount;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getAmount() {
        return amount;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    public BigDecimal getTotal() {
        return total;
    }

    public void setTotal(BigDecimal total) {
        this.total = total;
    }

    public Date getLastBuyDate() {
        return lastBuyDate;
    }

    public void setLastBuyDate(Date lastBuyDate) {
        this.lastBuyDate = lastBuyDate;
    }

    public Boolean getOriginalProcess() {
        return originalProcess;
    }

    public void setOriginalProcess(Boolean originalProcess) {
        this.originalProcess = originalProcess;
    }

    @Override
    public int compareTo(PurchaseBillDetails o) {
        if (this.getFoodMaterialId().longValue() > o.getFoodMaterialId().longValue()) return 1 ;
        else if (this.getFoodMaterialId().longValue() == o.getFoodMaterialId().longValue()) return 0;
        else return -1 ;
    }
}
